1
general::
Be the most outstanding in some respect, either the best or the worst. For example, That advertising slogan really took the cake, or What a mess they made of the concert? that takes the cake! This expression alludes to a contest called a cakewalk, in which a cake is the prize. Its figurative use, for something either excellent or outrageously bad, dates from the 1880s.
American Heritage Idioms